#!/usr/bin/python3
# -*- coding: utf-8 -*-
import json

import httpx


def main():
    # 定义请求url
    # url = "https://spa16.scrape.center/"
    url = 'https://www.iesdouyin.com/share/user/92662361468?did=MS4wLjABAAAAB7VdXH9djTK-Uu6oGX837RKKM8rzZXN1fxocaVACsX59bNta3WoaMtH7WeQ74XE5&iid=MS4wLjABAAAAS1G_N3nG8AfmXnecgLctEIaRtcnzBX6hPaAgIKQ-obpKj4hgjmVdU_trq5nbgNDW&with_sec_did=1&u_code=1272l5ckl&sec_uid=MS4wLjABAAAA_B8LcNff4fb3msMjEHewVT35hS0LILDm4s3g1kPfFl8&timestamp=1623287657&utm_source=copy&utm_campaign=client_share&utm_medium=android&share_app_name=douyin'
    # 定义请求头
    headers = {
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"
    }
    client = httpx.Client(http2=True, verify=False)
    response = client.get(url=url, headers=headers)
    # 方式一:直接转换json方法
    # results = response.json()
    # 方式二: 手动转换
    # 获取字节串
    content = response.content
    code = response.status_code
    html = str(content, 'utf-8')
    # print('content=', content)
    print('code=', code)
    print('html', html)
    # # 转换成字符串
    # string = content.decode('utf-8')
    # # 把字符串转成python数据类型
    # results = json.loads(string)
    # print('results', results)


if __name__ == '__main__':
    main()
